* Set current directory and open log
cd "E:\Seagate Sync\VOL\My Documents\Research\Current projects\prlx\Posted\101113 EUP publication\Data analysis"
capture log close
log using "prlx-v01-management02", replace text


*************************************************************************
* Variables for start date, type of instrument, and legislative procedure
*************************************************************************


* Project and author information
********************************
* Project:		prlx
* Programme:	prlx-v01-management02.do
* Date:			20 November 2010
* Author:		Frank Haege, University of Limerick
* Contact:		frank.haege@ul.ie 

* Do-file description
*********************
* This do-file takes the dataset of relevant EUPOL variables
* generated by the R-script 'prlx-v01-management01.r' and 
* constructs variables for the start date of the decision-making process,
* the type of instrument, and the type of legislative procedure.
* Using the start date variable, the temporal domain of the dataset is
* restricted to proposals introduced between 1976 and 2009.


* Clear memory  
**************
version 11.0
clear all
macro drop _all
set more off


* Load dataset of relevant EUPOL variables
******************************************

* Increase memory size
set memory 800m

* Load dataset
insheet using "prlx-v01-management01.csv", comma names case clear

* Rename proposal code variable
rename propCode propcode
label var propcode "Proposal code"

* Rename procedure code variable
rename procCode proccode
label var proccode "Procedure code"

* Label variables
label var title "Proposal title"
label var webno "PreLex webpage numer"


* Restrict dataset to study time period
***************************************

* Correct obvious Prelex errors in Commission adoption information
replace adopByComm_date_0 = "29-10-1986" if adopByComm_date_0 == "29-10-0986"
replace adopByComm_date_0 = "08-09-1982" if adopByComm_date_0 == "08-09-1820"

* Generate Commission adoption date variable
generate dateadop = .
replace dateadop = date(adopByComm_date_0, "DMY")
label var dateadop "Date of adoption by Commission"

* Generate transmission to Council date variables
generate datetrans = .
replace datetrans = date(tranToCoun_date_0, "DMY")
label var datetrans "Date of transmission to Council"

* Generate start of decision-making process variable
generate startdate = .
replace startdate = dateadop
label var startdate "Start date"
tab startdate if startdate == ., m

* Use transmission to Council date if Commission adoption date is missing
replace startdate = datetrans if startdate == .
tab startdate if startdate == ., m

* Generate year variable for start of decision-making process
generate year = year(startdate)
label var year "Start year"
tab year, m

* Generate month variable for start of decision-making process
generate month = month(startdate)
label var month "Starth month"
tab month, m

* Inspect observations with missing start date
list webno propcode proccode title if year == .
* Most files do not have a title
list webno propcode proccode title if year == . & title != "NA"

* Drop observations if start year is missing
drop if year == .
* 198 observations deleted (most of them do not contain any substantive content)
tab year, m

* Inspect patterns of proposal introduction during the first years covered by Prelex
tab month if year == 1975
tab month if year == 1976
tab month if year == 1977
tab month if year == 1978
tab month if year == 1979
tab year, m
* proposals in 1975 are unusually low, especially in first half

* Drop observations outside the study period
drop if year <= 1975
drop if year >= 2010
tab year, m


* Generate legal instrument variable
************************************

* Generate Commission adoption type of file variable
rename adopByComm_0_typeOfFile_0 ftypeadop
replace ftypeadop = "" if ftypeadop == "NA"

* Generate transmission to Council type of file variable
rename tranToCoun_0_typeOfFile_0 ftypetrans
replace ftypetrans = "" if ftypetrans == "NA"

* Generate final Commission type of file variable
rename typeOfFile_commission_0 ftypecom
replace ftypecom = "" if ftypecom == "NA"

* Generate final Council type of file variable
rename typeOfFile_council_0 ftypecoun
replace ftypecoun = "" if ftypecoun == "NA"

* Compare type of file variables
tab ftypeadop, m
tab ftypetrans, m
tab ftypecom, m
tab ftypecoun, m

* Generate Commission adoption instrument variable 
generate instadop = .
* Generate transmission to Council instrument variable
generate insttrans = .
* Generate final Commission instrument variable
generate instcom = .
* Generate final Council instrument variable
generate instcoun = .

* Define labels for instrument variable values
label def instrumentl /*
	*/ 0 "Non-legislative proposal" /*
	*/ 1 "Decision" /*
	*/ 2 "Regulation" /*
	*/ 3 "Directive" /*
	*/ 4 "Report" /*
	*/ 5 "Declaration" /*
	*/ 6 "Protocol" /*
	*/ 7 "Recommendation" /*
	*/ 8 "Resolution" /*
	*/ 9 "Green paper" /*
	*/ 10 "Letter" /*
	*/ 11 "Letter of amendment" /*
	*/ 12 "Memorandum" /*
	*/ 13 "Opinion" /*
	*/ 14 "Periodic report" /*
	*/ 15 "Preliminary draft supplementary budget" /*
	*/ 16 "Preliminary draft budget" /*
	*/ 17 "Programme" /*
	*/ 18 "Framework decision" /*
	*/ 19 "Assent" /*
	*/ 20 "Transfer of appropriations" /*
	*/ 21 "White paper" /*
	*/ 22 "Working paper" /*
	*/ 23 "Communication" /*
	*/ 24 "Agreement" /*
	*/ 25 "Declaration" /*
	*/ 26 "Common position" /*
	*/ 27 "Joint action" /*
	*/ 28 "ECSC budget" /*
	*/ 29 "Interinstitutional agreement" /*
	*/ 30 "Act" /*
	*/ 31 "Note" /*
	*/ 32 "Treaty" /*
	*/ 33 "Member states agreement" /*
	*/ 34 "EP resolution" /*
	*/ 35 "Other" /*
	*/ , modify
	
* Loop through the different instrument variables
foreach key in adop trans com coun { 
	* Code values for instrument variable from information in type of file variable
	* Missing values
	replace inst`key' = . if ftype`key' == ""
	* Decisions
	replace inst`key' = 1 if /*
		*/ ftype`key' == "decision" | /*
		*/ ftype`key' == "draft decision" | /*
		*/ ftype`key' == "proposal for a decision" | /*
		*/ ftype`key' == "recommendation for a decision" | /*
		*/ ftype`key' == "commission:proposal for a decision" | /*
		*/ ftype`key' == "commission:proposal for a directive;council:decision"
	* Regulations
	replace inst`key' = 2 if /*
		*/ ftype`key' == "regulation" | /*
		*/ ftype`key' == "draft regulation" | /*
		*/ ftype`key' == "proposal for a regulation" | /*
		*/ ftype`key' == "recomm. for a regulation" 
	* Directives
	replace inst`key' = 3 if /*
		*/ ftype`key' == "directive" | /*
		*/ ftype`key' == "draft directive" | /*
		*/ ftype`key' == "proposal for a directive"
	* Reports
	replace inst`key' = 4 if ftype`key' == "report"
	* Declarations
	replace inst`key' = 5 if ftype`key' == "draft declaration"
	* Protocols
	replace inst`key' = 6 if ftype`key' == "draft protocol"
	* Recommendations
	replace inst`key' = 7 if ftype`key' == "draft recommendation" /*
		*/ | ftype`key' == "proposal for a recommendation" /*
		*/ | ftype`key' == "recomm. for a recommendation" /*
		*/ | ftype`key' == "recommendation" 
	* Resolutions
	replace inst`key' = 8 if ftype`key' == "draft resolution" /*
		*/ | ftype`key' == "proposal for a resolution" /*
		*/ | ftype`key' == "resolution"
	* Green papers
	replace inst`key' = 9 if ftype`key' == "green paper"
	* Letters
	replace inst`key' = 10 if ftype`key' == "letter"
	* Letters of amendment
	replace inst`key' = 11 if ftype`key' == "letter of amendment"
	* Memoranda
	replace inst`key' = 12 if ftype`key' == "memorandum"
	* Opinions
	replace inst`key' = 13 if ftype`key' == "opinion" | ftype`key' == "recommendation for an opinion" 
	* Periodic reports
	replace inst`key' = 14 if ftype`key' == "periodic report"
	* Budget supplements
	replace inst`key' = 15 if ftype`key' == "prelim. draft supplem. budget" /*
		*/ | ftype`key' == "supplem. and amending budet"
	* Budgets
	replace inst`key' = 16 if ftype`key' == "preliminary draft budget"
	* Programmes
	replace inst`key' = 17 if ftype`key' == "programme"
	* Council framework decisions
	replace inst`key' = 18 if ftype`key' == "proposal for a council framework decision" /*
		*/ | ftype`key' == "draft council framework decision" | ftype`key' == "council framework decision" 
	* Council assents
	replace inst`key' = 19 if ftype`key' == "request for council assent" /*
		*/ | ftype`key' == "council assent"
	* Transfer of appropriations
	replace inst`key' = 20 if ftype`key' == "transfer of appropriations"
	* White papers
	replace inst`key' = 21 if ftype`key' == "white paper"
	* Working papers
	replace inst`key' = 22 if ftype`key' == "working paper" | ftype`key' == "staff working paper"
	* Communications
	replace inst`key' = 23 if ftype`key' == "communication" | ftype`key' == "draft communication"
	* Agreements
	replace inst`key' = 24 if ftype`key' == "agreement" | ftype`key' == "draft agreement"
	* Declarations
	replace inst`key' = 25 if ftype`key' == "declaration" | ftype`key' == "proposal for a declaration"
	* Common positions
	replace inst`key' = 26 if ftype`key' == "draft common position" /*
		*/ | ftype`key' == "proposal for a common position" | ftype`key' == "common position"
	* Joint actions
	replace inst`key' = 27 if ftype`key' == "joint action" | ftype`key' == "proposal for a joint action"
	* ESCS budgets
	replace inst`key' = 28 if ftype`key' == "ecsc budget" | ftype`key' == "draft ecsc budget"
	* Interinstitutional agreements
	replace inst`key' = 29 if ftype`key' == "draft interinstitut. agreement" /*
		*/ | ftype`key' == "interinstitutional agreement"
	* Acts
	replace inst`key' = 30 if ftype`key' == "proposal for an act" /*
		*/ | ftype`key' == "act" | ftype`key' == "draft act" 
	* Notes
	replace inst`key' = 31 if ftype`key' == "note"
	* Treaties
	replace inst`key' = 32 if ftype`key' == "draft treaty"
	* Agreements between member states
	replace inst`key' = 33 if ftype`key' == "agreement betw. member states" /*
		*/ | ftype`key' == "draft agreement member states"
	* EP resolutions
	replace inst`key' = 34 if ftype`key' == "resolution of ep"
	* Label instrument variable values
	label val inst`key' instrumentl
}

* Check instrument variables
tab instadop, m
tab insttrans, m
tab instcom, m
tab instcoun, m

* Generate general instrument variable from Commission adoption instrument variable
generate instrument = instadop
label value instrument instrumentl
label var instrument "Legal instrument"

* Replace missing values by values of transmission to Council instrument variable
tab instadop insttrans, m
replace instrument = insttrans if instadop == .

* Replace missing values by values of final Commission instrument variable
tab instrument instcom, m
replace instrument = instcom if instrument == .

* Replace missing values by values of final Council instrument variable
tab instrument instcoun, m
replace instrument = instcoun if instrument == .

* Code most remaining missing values from information in the title of the proposals
tab instrument, m
list webno proccode propcode title if instrument == .
replace instrument = 22 if instrument == . & regexm(title, "commission staff working")
replace instrument = 30 if instrument == . & regexm(title, "council act")
replace instrument = 22 if instrument == . & regexm(title, "commission working document")
replace instrument = 1 if instrument == . & regexm(title, "council decision")
replace instrument = 1 if instrument == . & regexm(title, "proposal for a decision")
replace instrument = 12 if instrument == . & regexm(title, "aide-memoire")
replace instrument = 23 if instrument == . & regexm(title, "communication")
* Still four missing values that do not clearly fit into any category

* Generate type of legal instrument variable
generate instagg = .
* Legislative instruments
replace instagg = 1 if /*
	*/ instrument == 1 | /*
	*/ instrument == 2 | /*
	*/ instrument == 3
* Non-legislative instruments
replace instagg = 2 if /*
	*/ (instrument >= 4 & /*
	*/ instrument <= 14) | /*
	*/ instrument == 17 | /*
	*/ instrument == 21 | /*
	*/ instrument == 22 | /*
	*/ instrument == 23 | /*
	*/ instrument == 25 | /*
	*/ instrument == 31 | /*
	*/ instrument == 34 
* Budgetary instruments
replace instagg = 3 if /*
	*/ instrument == 15 | /*
	*/ instrument == 16 | /*
	*/ instrument == 28 | /*
	*/ instrument == 20	
* Other binding instruments
replace instagg = 4 if /*
	*/ instrument == 18 | /*
	*/ instrument == 19 | /*
	*/ instrument == 24 | /*
	*/ instrument == 26 | /*
	*/ instrument == 27 | /*
	*/ instrument == 29 | /*
	*/ instrument == 30 | /*
	*/ instrument == 32 | /*
	*/ instrument == 33 
label def instaggl /*
	*/ 1 "Legislative acts" /*
	*/ 2 "Non-legislative acts" /*
	*/ 3 "Budgetary acts" /*
	*/ 4 "Other binding acts"
label val instagg instaggl
tab instagg, m


* Generate legislative procedure variable
*****************************************

* Generate Commission adoption procedure variable
rename adopByComm_0_procedures_0 procadop
replace procadop = "" if procadop == "NA"
tab procadop, m

* Generate transmission to Council procedure variable
rename tranToCoun_0_procedures_0 proctrans
replace proctrans = "" if proctrans == "NA"
tab proctrans, m

* Generate final Commission procedure variable
rename procedures_commission_0 proccom
replace proccom = "" if proccom == "NA"
tab proccom, m

* Generate final Council procedure variable
rename procedures_council_0 proccoun
replace proccoun = "" if proccoun == "NA"
tab proccoun, m

* Generate final Parliament procedure variable
rename procedures_euroParl_0 procep
replace procep = "" if procep == "NA"
tab procep, m

* Generate final member state procedure variable
rename procedures_etatMemb_0 procmemb
replace procmemb = "" if procmemb == "NA"
tab procmemb, m

* Generate general procedure variable from Commission adoption procedure variable
generate procedure = ""
replace procedure = procadop

* Replace missing values by values of transmission to Council variable
tab procadop proctrans, m
replace procedure = proctrans if procedure == ""

* Replace missing values by values of final Commission procedure variable
tab procedure proccom, m
replace procedure = proccom if procedure == ""

* Replace missing values by values of final Council procedure variable
tab procedure proccoun, m
replace procedure = proccoun if procedure == ""

* Replace missing values by values of final Parliament procedure variable
tab procedure procep, m
replace procedure = procep if procedure == ""

* Replace missing values by values of final member state procedure variable
tab procedure procmemb, m


* Update procedure variable with information about EP readings
**************************************************************

* Rename and recode missing values of EP variables
rename tranToEp_date_0 transep
replace transep = "" if transep == "NA"
rename epCtteRepo1stRdg_date_0 epreportfirstd
replace epreportfirstd = "" if epreportfirstd == "NA"
rename epOpin1stRdg_date_0 epopinionfirstd
replace epopinionfirstd = "" if epopinionfirstd == "NA"
rename epCtteRepoSingRdg_date_0 epreportsingled
replace epreportsingled = "" if epreportsingled == "NA"
rename epOpinSingRdg_date_0 epopinionsingled
replace epopinionsingled = "" if epopinionsingled == "NA"

* Generate transmission to EP dummy variable
generate transepd = 0
replace transepd = 1 if transep ~= ""

* Generate EP first reading dummy variable
generate epfirstd = 0
replace epfirstd = 1 if (epreportfirstd ~= "" | epopinionfirstd ~= "")
label var epfirstd "EP opinion first reading (yes/no)"

* Generate EP single reading dummy variable
generate epsingled = 0
replace epsingled = 1 if (epreportsingled ~= "" | epopinionsingled ~= "")
label var epsingled "EP opinion single reading (yes/no)"

* Generate EP reading dummy variable
generate epd = 0
replace epd = 1 if epsingled == 1 | epfirstd == 1

* Generate EP involvement dummy variable
generate epinvolve = 0
replace epinvolve = 1 if epd == 1 | transepd == 1

* Check which types of procedures have EP single readings
tab procedure epsingled, row m
* EP single readings occur almost exclusively under the consultation procedure

* Check what proportion of EP single readings with known procedure are conducted under the consultation procedure
tab procedure epsingled, col
* The overwhelming majority (99%) of cases for which the procedure is known are consultation files

* Recode proposals with missing values and EP single readings to consultation
replace procedure = "consultation procedure" if epsingled == 1 & procedure == ""
tab procedure epsingled , m

* Check which types of procedures have EP first readings
tab procedure epfirstd, row m
* EP first readings occur almost exclusively under the cooperation and codecision procedure

* Check what proportion of EP first readings with known procedure are conducted under the cooperation and codecision procedure
tab procedure epfirstd, col
* EP overwhelming majority (98%) of cases for which the procedure is known are cooperation or codecision files

* Check proposals with missing values and EP first readings
format %td startdate
list webno instrument proccode startdate formAdopByCoun_date_0 signByEpAndCoun_date_0 if procedure == "" & epfirstd == 1
* They were either consultation or cooperation files when introduced

* Recode proposals with missing values that were introduced before 1987 to consultation files
replace procedure = "consultation procedure" if procedure == "" & epfirstd == 1 & year < 1987

* Recoded the remaining missing values to cooperation files
replace procedure = "cooperation procedure" if procedure == "" & epfirstd == 1

* Code non-legislative acts as "No-procedure"
tab procedure instagg, m
replace procedure = "No procedure" if instagg == 2 | instagg == 3 | instagg == 4
tab procedure, m

* Generate procedure variable that takes procedure at start of process as correct procedure value
tab year procedure if procedure == "codecision procedure" /*
	*/ | procedure == "consultation procedure" | procedure == "cooperation procedure", m
generate procedurec = procedure

* Recode cooperation or codecision procedure values before SEA in 1987 to consultation
replace procedurec = "consultation procedure" if (year < 1987 | (year == 1987 & month < 7)) & procedurec == "codecision procedure"	
replace procedurec = "consultation procedure" if (year < 1987 | (year == 1987 & month < 7)) & procedurec == "cooperation procedure"	

* Recode codecision procedure values before Maastricht Treaty in 1993 to cooperation
replace procedurec = "cooperation procedure" if (year < 1993 | (year == 1993 & month < 11)) & procedurec == "codecision procedure"	

* Check cooperation procedure proposals after Amsterdam Treaty in 1999
list webno if year > 1999 & procedurec == "cooperation procedure"
* Cooperation procedure in 2005 seems to be correct

* Check new procedure variable
tab year procedurec if procedurec == "codecision procedure" /*
	*/ | procedurec == "consultation procedure" | procedurec == "cooperation procedure", m

* Check procedure coding when there is no EP involvement
tab epinvolve procedure, m
list webno if epinvolve == 0 & procedure ~= "" in 1/100
* Mostly international agreements and implementing legislation, no consultation or codecision procedures

* Recode proposals with no EP involvement to 'No procedure'
tab procedure epinvolve, m
replace procedure = "No procedure" if epinvolve == 0 & procedure == ""
replace procedurec = "No procedure" if epinvolve == 0 & procedurec == ""
tab procedure epinvolve, row m
tab procedure epinvolve, col


* Generate decision-making event dummy variables
************************************************

* Generate EP and Council signature dummy
generate signature = 0
replace signature = 1 if signByEpAndCoun_date_0 != "NA"
label var signature "Signature by EP and Council (yes/no)"

* Generate partial EP and Council signature dummy
generate partsign = 0
replace partsign = 1 if partSignByEpAndCoun_date_0 != "NA"
label var partsign "Partial signature by EP and Council (yes/no)"

* Generate Council agreement dummy
generate cagree = 0
replace cagree = 1 if counAgre_date_0 ~= "NA"
label var cagree "Council agreement (yes/no)"

* Generate Council formal adoption dummy
generate cfadopt = 0
replace cfadopt = 1 if formAdopByCoun_date_0 ~= "NA"
label var cfadopt "Formal adoption by Council (yes/no)"

* Generate Council political agreement on common position dummy
generate cpagree = 0
replace cpagree = 1 if polAgreCommPosi_date_0 ~= "NA"
label var cpagree "Political agreement Common Position (yes/no)"

* Generate Council adoption of common position dummy
generate cpaadopt = 0
replace cpaadopt = 1 if adopCommPosi_date_0 ~= "NA"
label var cpaadopt "Adoption Common Position (yes/no)"

* Generate Council approval first reading dummy
generate capproval = 0
replace capproval = 1 if counAppr1stRdg_date_0 ~= "NA"
label var capproval "Council approval first reading (yes/no)"

* Generate Council partial adoption dummy
generate cpartadopt = 0
replace cpartadopt = 1 if partAdopByCoun_date_0 ~= "NA"
label var cpartadopt "Partial adoption by Council (yes/no)"

* Generate Council approval second reading dummy
generate capproval2 = 0
replace capproval2 = 1 if counAppr2ndRdg_date_0 ~= "NA"
label var capproval2 "Council approval second reading (yes/no)"


* Generate Council decision third reading dummy
generate capproval3 = 0
replace capproval3 = 1 if counDeciAt3rdRdg_date_0 ~= "NA"
label var capproval3 "Council approval third reading (yes/no)"

* Generate withdrawal by Commission dummy
generate withdraw = 0
replace withdraw = 1 if withByComm_date_0 ~= "NA"
label var withdraw "Withdrawal by Commission (yes/no)"

* Generate replacement dummy
generate repl = 0
replace repl = 1 if replacement_date_0 ~= "NA"
label var repl "Replacement by Commission (yes/no)"

* Generate rejection by Council dummy
tab rejeByCoun_date_0 procedure, m
* Rejections do not occur in legislative procedures

* Generate no adoption by Council dummy
tab noAdopByCoun_date_0 procedure, m
* Only three cases with legislative procedure, most likely errors

* Generate EP second reading dummy
generate epsecondd = 0
replace epsecondd = 1 if epOpin2ndRdg_date_0 ~= "NA"
label var epsecondd "EP opinion second reading (yes/no)"

* Generate EP third reading
generate epthirdd = 0
replace epthirdd = 1 if epDeciOn3rdRdg_date_0 ~= "NA"
label var epthirdd "EP opinion third reading (yes/no)"


* Further recoding of procedure variable
****************************************

* Generate general Council non-codecision adoption variable (for coding procedure variable)
generate cdec = 0
* Formal adoption by Council
replace cdec = 1 if cfadopt == 1
* Council agreement
tab cdec cagree if procedure == "", m
replace cdec = 1 if cdec == 0 & cagree == 1
* Partial adoption by Council
tab cdec cpartadopt if procedure == "", m
replace cdec = 1 if cdec == 0 & cpartadopt == 1
label value cdec yesno
tab cdec, m

* Check cases with EP transmission and Council adoption, but no EP reading
list webno title propcode proccode if cdec == 1 & procedure == "" in 1/1000
* These proposals refer mostly to international agreements, administrative or institutional decisions, or implementing law

* Code cases with EP transmission and Council adoption, but no EP reading as 'No procedure'
tab procedure cdec, m
replace procedure = "No procedure" if cdec == 1 & procedure == ""
tab procedure cdec, m
replace procedurec = "No procedure" if cdec == 1 & procedurec == ""

* Correct idiosyncratic procedure error
* This is a budgetary, not a codecision procedure (error was discovered during later stages of the analysis)
replace procedure = "" if webno == 163005
replace procedurec = "" if webno == 163005

* Examine remaining cases with EP transmission but no EP reading, and no Council adoption or signature
list title webno proccode instrument if procedure == ""
* Mostly international agreements, Commission decisions and other implementing acts, as well as budgetary proposals

* Code all remaining proposals as "No procedure"
tab procedurec, m sort
replace procedure = "No procedure" if procedure == ""
replace procedurec = "No procedure" if procedurec == ""
tab procedurec, m sort

* Recode "non-legislative procedure" to "No procedure"
tab procedurec, m sort
replace procedure = "No procedure" if procedure == "non-legislative procedure"
replace procedurec = "No procedure" if procedurec == "non-legislative procedure"
tab procedurec, m sort

* Generate numerical procedure variable
generate procstr = procedure
drop procedure
generate procedure = .
replace procedure = 0 if procstr == "No procedure"
replace procedure = 1 if procstr == "consultation procedure"
replace procedure = 2 if procstr == "cooperation procedure"
replace procedure = 3 if procstr == "codecision procedure"
replace procedure = 4 if procstr == "assent procedure"
replace procedure = 5 if procstr == "agreement"
replace procedure = 6 if procstr == "consultation court of auditors"
replace procedure = 7 if procstr == "consultation eur. central bank"
replace procedure = 8 if procstr == "social protocol"
replace procedure = 9 if procstr == "special legislative procedure (ep consent required)"
drop procstr

* Label numerical procedure variable
label def procedurel /*
	*/ 0 "No procedure" /*
	*/ 1 "Consultation" /*
	*/ 2 "Cooperation" /*
	*/ 3 "Codecision" /*
	*/ 4 "Assent" /*
	*/ 5 "Agreement" /*
	*/ 6 "Consultation CoA" /*
	*/ 7 "Consultation ECB" /*
	*/ 8 "Social Protocol" /*
	*/ 9 "Special Legislative" /*
	*/ 10 "Other", modify
label val procedure procedurel
label var procedure "Legislative procedure"
tab procedure, m sort

* Generate numerical procedure variable (procedure coded at start of process)
generate procstr = procedurec
drop procedurec
generate procedurec = .
replace procedurec = 0 if procstr == "No procedure"
replace procedurec = 1 if procstr == "consultation procedure"
replace procedurec = 2 if procstr == "cooperation procedure"
replace procedurec = 3 if procstr == "codecision procedure"
replace procedurec = 4 if procstr == "assent procedure"
replace procedurec = 5 if procstr == "agreement"
replace procedurec = 6 if procstr == "consultation court of auditors"
replace procedurec = 7 if procstr == "consultation eur. central bank"
replace procedurec = 8 if procstr == "social protocol"
replace procedurec = 9 if procstr == "special legislative procedure (ep consent required)"
drop procstr

* Label numerical procedure variable
label def procedurel /*
	*/ 0 "No procedure" /*
	*/ 1 "Consultation" /*
	*/ 2 "Cooperation" /*
	*/ 3 "Codecision" /*
	*/ 4 "Assent" /*
	*/ 5 "Agreement" /*
	*/ 6 "Consultation CoA" /*
	*/ 7 "Consultation ECB" /*
	*/ 8 "Social Protocol" /*
	*/ 9 "Special Legislative" /*
	*/ 10 "Other", modify
label val procedurec procedurel
label var procedurec "Legislative procedure (start)"
tab procedurec, m sort

* Drop irrelevant event variables
drop adopAmenProp* tranToEp* typeOfFile* adopByComm* chanOfLegaBasiByComm* /*
	*/ commPosiOnEpAmenOn1stRead* epCtteRepo1stRdg* epCtteRepoSingRdg* epOpin1stRdg* epOpinSingRdg* /*
	*/ rejeByCoun* v* commPosiOnEpAmenOnSingRead* tranAmenPropToCoun* tranAmenPropToCoun* tranAmenPropToEp* /*
	*/  epDeciOn3rdRdg* epOpin2ndRdg* noAdopByCoun* tranToCoun*

* Keep only relevant variables	
keep proccode propcode title webno dateadop datetrans startdate year month instrument procedurec /*
	*/ epsingled epfirstd epsecondd epthirdd signature partsign /*
	*/ cagree cfadopt cpagree cpaadopt capproval capproval2 capproval3 cpartadopt withdraw repl *_date_*

* Order the remaining variables
order webno propcode proccode title dateadop datetrans startdate year month instrument procedurec /*
	*/ cagree cfadopt cpartadopt cpagree cpaadopt capproval capproval2 capproval3 /*
	*/ epsingled epfirstd epsecondd epthirdd signature partsign repl withdraw *_date_*
	
* Sort and save dataset
sort webno
compress
save "prlx-v01-management02.dta", replace
log close
exit
